package com.example.loginregister.Tools

import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.commit
import com.example.loginregister.R

fun Fragment.navigateTo(
    target: Fragment,
    enterAnim: Int = R.anim.enter_from_right,
    exitAnim: Int = R.anim.exit_to_left,
    popEnterAnim: Int = R.anim.pop_enter_from_left,
    popExitAim: Int = R.anim.pop_exit_to_right,
    isAddToBack: Boolean = true
) {
    parentFragmentManager.commit {
        setCustomAnimations(enterAnim, exitAnim, popEnterAnim, popExitAim)
        setReorderingAllowed(true)
        replace(R.id.FragmentContainerView, target)
        if (isAddToBack) {
            addToBackStack(null)
        }
    }
}

fun View.dpToPx(dp:Int):Float{
    return dp * resources.displayMetrics.density
}
